1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
use super::*;
#[derive(Completer, Helper, Highlighter)]
pub struct IsotopeHelper {
hinter: HistoryHinter,
}
impl IsotopeHelper {
pub fn new() -> IsotopeHelper {
IsotopeHelper {
hinter: HistoryHinter {},
}
}
}
impl Validator for IsotopeHelper {
fn validate(&self, ctx: &mut ValidationContext) -> Result<ValidationResult, ReadlineError> {
match terminated(many0_count(preceded(opt(ws), command)), opt(ws))(ctx.input()) {
Ok(("", _n)) => Ok(ValidationResult::Valid(None)),
Ok((_rest, _n)) => Ok(ValidationResult::Incomplete),
Err(err) => Ok(ValidationResult::Invalid(Some(format!(
"Parse error: {:#?}",
err
)))),
}
}
}
impl Hinter for IsotopeHelper {
type Hint = String;
fn hint(&self, line: &str, pos: usize, ctx: &Context<'_>) -> Option<String> {
self.hinter.hint(line, pos, ctx)
}
}